package gameclasses;

import java.util.Vector;

import datastructures.Vector2f;

import interfaces.IUnit;

public class Player {

	private GameManager gm;
	private int ID;
	private int money=0;
	private int points=0;
	private final Vector2f unitspawn;
	private boolean isGameOver;
	
	public Player(GameManager gm, int ID, int StartingMoney, Vector2f unitSpawn)
	{
		money = StartingMoney;
		unitspawn = unitSpawn;
		this.gm = gm;
	}
	
	public int getMoney() {
		return money;
	}	

	public int getPoints() {
		return points;
	}

	public void addPoints(int points) {
		this.points += points;
	}
	
	public void pay(int money)
	{
		this.money -= money;
	}
	
	public Vector2f getUnitSpawn()
	{
		return unitspawn;
	}
	
	public int checkGameOver()
	{
		Vector<IUnit> units = gm.getUnitsOf(ID);
		
		if (units.isEmpty()&&(money<=0))
		{
			isGameOver = true;
		}
		return isGameOver();
	}
	
	public int isGameOver()
	{
		return (isGameOver==true) ? exceptions.Exception.PLAYER_GAME_OVER : exceptions.Exception.PLAYER_OK;
	}
	
}
